package com.wavehi.consumer;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.wavehi.util.RabbitMQFactoryUtils;


/**
 * @Description
 * @Author WaveHi
 * @Date 26/12/2021 下午 8:19
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 */
public class Consumer_01 {
    //队列名
    private static final String QUEUE_NAME = "publishConfirm";
    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMQFactoryUtils.getChannel();
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println(message);
            channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
        };
        CancelCallback cancelCallback = consumerTag -> {
            System.out.println("Stop!");
        };
        channel.basicConsume(QUEUE_NAME, false, deliverCallback, cancelCallback);
    }
}
